% Piecewise linear force [Vectorization Version]
% PL_Data = [k1,k2,B1,B2]
function fNL = Piecewise_Linear_Force(PL_Data,xs)
	NP = 1024;
    fNL=zeros(NP+1,size(xs,2));
    k1=PL_Data(1);k2=PL_Data(2);B1=PL_Data(3);B2=PL_Data(4);

	index1 = (xs>=-B1)&(xs<B1);													% Case 1
	index2 = (xs>=B1)&(xs<B2); 													% Case 2
	index3 = (xs>=-B2)&(xs<-B1);												% Case 3
	index4 = (xs<-B2);															% Case 4
	index5 = (xs>=B2);															% Case 5
	fNL = fNL - (k1.*double(index1).*xs );
	fNL = fNL - (k1*B1.*double(index2) + k2.*double(index2).*(xs-B1));
	fNL = fNL - (-k1*B1.*double(index3) + k2.*double(index3).*(xs+B1)); 
	fNL = fNL - (k1*B1.*double(index4) + k2.*double(index4).*(B2-B1) + k1.*double(index4).*(xs-B2));
	fNL = fNL - (-k1*B1.*double(index5) + k2.*double(index5).*(-B2+B1) + k1.*double(index5).*(xs+B2));
end